package org.aiforum.web.action;

import java.util.List;

import org.aiforum.domain.Reply;
import org.aiforum.domain.Topic;
import org.aiforum.frountend.common.Pageing;
import org.aiforum.web.common.AiActionContext;


/**
 * 帖子请求Action
 * @author VIC
 *
 */
public class TopicAction extends AiActionContext {

	private static final long serialVersionUID = 1L;
	
	private Pageing pageing = new Pageing();
	private Topic topic = new Topic();
	
	/**
	 * 根据板块分页查询显示帖子
	 * @return
	 */
	public String query_by_plateid(){
		pageing.setActionName("topic_query_by_plateid");
		pageing = topicService.queryPageingByPlateId(pageing);
		request.setAttribute("pageing", pageing);
		return SUCCESS;
	}
	
	/**
	 * 根据标题模糊分页查询显示帖子
	 * @return
	 */
	public String query_like_title(){
		pageing.setActionName("topic_query_like_title");
		pageing = topicService.queryPageingLikeTitle(pageing);
		request.setAttribute("pageing", pageing);
		return SUCCESS;
	}
	
	/**
	 * 显示帖子列表
	 * @return
	 */
	public String query_list(){
		pageing.setActionName("topic_query_list");
		pageing = topicService.queryPageingAll(pageing);
		request.setAttribute("pageing", pageing);
		return SUCCESS;
	}
	
	public String findById(){
		// 查询主帖子信息
		topic = topicService.findById(topic.getTopicId());
		// 查询回复帖子列表
		List<Reply> replys = replyService.queryByTopicId(topic.getTopicId());
		
		request.setAttribute("replys", replys);
		request.setAttribute("topic", topic);
		return "topicinfo";
	}
	
	public Pageing getPageing() {
		return pageing;
	}
	public void setPageing(Pageing pageing) {
		this.pageing = pageing;
	}

	public Topic getTopic() {
		return topic;
	}

	public void setTopic(Topic topic) {
		this.topic = topic;
	}
	
}
